#!/bin/bash
 
cttuAPI="./cttuAPI"
 
function killProsess() {
	NAME=$1
	echo $NAME
        
    # 获取进程 PID
	# PID=$(ps -e | grep $NAME | awk '{print $1}') 
	PID=$(ps -ef|grep $NAME| grep -v grep | awk '{print $2}') 
	
	echo "PID: $PID"
    #  杀死进程
	kill -9 $PID
}
 
function start() {
	(nohup $cttuAPI 2>1 &) &&
	ps -ef | grep service
}
 
function stop() {
	killProsess $cttuAPI
}
 
function restart() {
	stop
	start
}
 
case "$1" in
	start )
		start
		echo "monitor start sucess"
		;;
	stop )
		stop
		echo "monitor stop sucess"
		;;
	restart )		
		restart
		echo "monitor restart sucess"
		;;
	* )
		echo "you can use ./svc start|stop|restart"
		;;
esac
